﻿using System;
using System.Collections.Generic;
using KPI.Data;
using KPI.Entity;
using TYBase;

namespace KPI.Api
{
    public class ScheduleApi
    {
        public static RPage<ScheduleVO> GetList(PageInfo page, ScheduleVO queryDto)
        {
            try
            {
                LocalHttp http = new LocalHttp();
                if (!http.SetBaseUri(KPIData.ServerURL)
                    .SetUrl($"/schedule/getList?{queryDto.AsQueryData()} &{page.AsQueryData()}")
                    .SetGet()
                    .Excute(out string data))
                {
                    return RPage<ScheduleVO>.Fail(data);
                }
                return data.AsModel<RPage<ScheduleVO>>();
            }
            catch (Exception ex)
            {
                return RPage<ScheduleVO>.Fail("获取字典失败!", ex);
            }
        }
        public static R<bool> Edit(List<Tbl_Schedule> queryDto)
        {
            try
            {
                LocalHttp http = new LocalHttp();
                if (!http.SetBaseUri(KPIData.ServerURL)
                    .SetUrl($"/schedule/editList")
                    .SetData(queryDto.JsonAsString())
                    .SetPost()
                    .Excute(out string data))
                {
                    return R<bool>.Fail(data);
                }
                return data.AsModel<R<bool>>();
            }
            catch (Exception ex)
            {
                return R<bool>.Fail("编辑排期失败!!", ex);
            }
        }
        public static R<ScheduleVO> Edit(Tbl_Schedule queryDto)
        {
            try
            {
                LocalHttp http = new LocalHttp();
                if (!http.SetBaseUri(KPIData.ServerURL)
                    .SetUrl($"/schedule/edit")
                    .SetData(queryDto.JsonAsString())
                    .SetPost()
                    .Excute(out string data))
                {
                    return R<ScheduleVO>.Fail(data);
                }
                return data.AsModel<R<ScheduleVO>>();
            }
            catch (Exception ex)
            {
                return R<ScheduleVO>.Fail("编辑排期失败!!", ex);
            }
        }
    }
}
